/*******************************************************
> Copyright (C) 2024 ==IOT== All rights reserved.
> File Name: inherit6.cpp
> Author: IOT
> Website:www.slq.org
> Created Time: 2024年10月25日 星期五 15时34分26秒
***************************************************/

#include <iostream>
using namespace std;

class A { // 虚基类
	public:
	int a;
};

class B : virtual public A { // 虚继承
	public:
	int b;
};

class C : virtual public A {
	public:
	int c;
};

class D : public B, public C {
	public:
	int d;
	
};

int main(int argc,const char* argv[])
{
	D d;
	cout << sizeof(d) << endl;
	
	d.d = 1;
	d.b = 2;
	d.c = 3;
	d.a = 4;
	
	int *p = (int *)&d;
	
	for (int i = 0;i < sizeof(d) / sizeof(int); i++) {
		cout << p + i << " : " << p[i] << endl;
	}
	
    return 0;
}
